<template>
<div class="container">
    <div class="nav3">
        <div>
            <img src="../../assets/img/热销媒体列表/切图/0.png"><span>排序:</span>
        </div>
        <ul>
            <li v-for="(item,index) in navList1" :key="index" @click="changeColor3(index)">
                <img :src="item[0]"><span :class="{red:index3==index,black:index3!=index}">{{item[1]}}</span>
            </li>
        </ul>
    </div>
    <div class="content">
      <ul class="list">
          <li v-for="(item,index) in result3" :key="index">
              <ul>
                  <li>
                      <img :src="item.logo" width="90px" height="90px" style="border-radius:50%;">
                      <img :src="smallIcon(index)" width="26px" height="26px" v-if="appNOshow">
                  </li>
                  <li>
                      <p>{{title1(index)}}</p>
                      <p>{{content1(index)}}</p>
                  </li>
                  <li v-if="appNOshowLi">
                      <p>所属类别</p>
                      <p>{{attachType(index)}}</p>
                  </li>
                  <li>
                      <p>{{title2(index)}}</p>
                      <p>{{content2(index)}}</p>
                  </li>
                  <li>
                      <p>{{title3(index)}}</p>
                      <p>{{content3(index)}}</p>
                  </li>
                  <li>
                      <p>{{title4(index)}}</p>
                      <p>{{content4(index)}}</p>
                  </li>
                  <li>
                      <p>参考价格</p>
                      <p>{{content5(index)}}元起</p>
                  </li>
                  <li>
                      <div><img :src="imgDel" alt="" @mouseover="imgchange1" @mouseout="imgchange2" @click="deleteCtrl(index)"></div>
                      <div><button>联系客服</button></div>
                      <div><button @click="$router.push({path:'/view2/shortVideoDetail',query:{id:item.id }})">查看详情</button></div>
                  </li>
              </ul>
          </li>
      </ul>
        <el-pagination class="page"
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :page-sizes="[10, 20, 50, 100]"
        :page-size="5"
        layout="total, sizes, prev, pager, next, jumper"
        :total="total">
        </el-pagination>
    </div>
</div>
</template>
<script>
const img5 = require("../../assets/img/热销媒体列表/切图/5.png");
const img2 = require("../../assets/img/收藏夹/切图/2.png");
const img3 = require("../../assets/img/收藏夹/切图/3.png");
const img9 = require("../../assets/img/热销媒体列表/切图/9.png");
const img10 = require("../../assets/img/收藏夹/切图/4.png");
const img11 = require("../../assets/img/收藏夹/切图/5.png");
const img12 = require("../../assets/img/收藏夹/切图/6.png");
const img13 = require("../../assets/img/收藏夹/切图/7.png");
const img14 = require("../../assets/img/收藏夹/切图/8.png");
export default {
  data() {
    return {
      navList1: [[img5, "综合"], [img5, "人气"], [img5, "价格"]],
      index3: 0,
      type: "",
      page: 1,
      limit: 10,
      order: "",
      sort: "ASC",
      orderList: ["03", "01", "02"],
      total: 0,
      userinfoid: "",
      result3: "",
      imgDel: img2,
      appNOshow:true,
      appNOshowLi:true
    };
  },
  methods: {
    // 删除收藏
    deleteCtrl(index) {
      console.log(
        this.userinfoid + this.result3[index].type + this.result3[index].id
      );
      this.$ajax
        .post(this.Ipurl + "favoriteInfo/delete", {
          userId: this.userinfoid + "",
          type: this.result3[index].type,
          popularMediaId: this.result3[index].id
        })
        .then(res => {
          if (res.data.returnCode == 1000) {
            this.$message("删除成功");
            this.$ajax
              .post(this.Ipurl + "favoriteInfo/getListById", this.args)
              .then(res => {
                this.result3 = res.data.dataInfo.records;
                console.log(this.result3);
              });
          } else {
            this.$message("删除失败");
          }
        });
    },
    // 排序
    changeColor3(index) {
      // for(let i = 0;i<this.navList1.length;i++){
      //   this.navList1[i][0] = img5
      // }
      // img9为降序标识
      if (this.navList1[index][0] == img5) {
        this.navList1[index][0] = img9;
      } else {
        this.navList1[index][0] = img5;
      }
      this.index3 = index;
      if (this.navList1[index][0] == img9) {
        this.sort = "DESC";
      } else {
        this.sort = "ASC";
      }
      this.order = this.orderList[index];
      this.$ajax
        .post(this.Ipurl + "favoriteInfo/getListById", this.args)
        .then(res => {
          this.total = res.data.dataInfo.total;
          this.result3 = res.data.dataInfo.records;
        });
    },
    imgchange1() {
      this.imgDel = img3;
    },
    imgchange2() {
      this.imgDel = img2;
    },
    handleSizeChange(val) {
      this.limit = val;
      console.log(this.args);
      this.$ajax
        .post(this.Ipurl + "favoriteInfo/getListById", this.args)
        .then(res => {
          this.result3 = res.data.dataInfo.records;
          console.log(this.result3);
        });
    },
    // 分页--页数
    handleCurrentChange(val) {
      this.page = val;
      console.log(this.args);
      this.$ajax
        .post(this.Ipurl + "favoriteInfo/getListById", this.args)
        .then(res => {
          this.result3 = res.data.dataInfo.records;
          console.log(this.result3);
        });
    },
    smallIcon(index) {
      if (this.result3[index].type == "短视频") {
        return img10;
      } else if (this.result3[index].type == "小红书号") {
        return img11;
      } else if (this.result3[index].type == "网易考拉海购号") {
        return img12;
      } else if (this.result3[index].type == "微信公众号") {
        return img13;
      } else if (this.result3[index].type == "微博大V号") {
        return img14;
      }else if(this.result3[index].type == "app"){
        this.appNOshow = false
      }
    },
    title1(index) {
      return this.result3[index].mediaName;
    },
    attachType(index) {
      return this.result3[index].type;
    },
    title2(index) {
      if (this.result3[index].type == "短视频") {
        return "所属平台";
      } else if (this.result3[index].type == "小红书号") {
        return "粉丝数";
      } else if (this.result3[index].type == "网易考拉海购号") {
        return "获赞量";
      } else if (this.result3[index].type == "微信公众号") {
        return "ID";
      } else if (this.result3[index].type == "微博大V号") {
        return "粉丝数";
      }else if(this.result3[index].type=="app"){
        return "月活"
      }
    },
    title3(index) {
      if (this.result3[index].type == "短视频") {
        return "ID";
      } else if (this.result3[index].type == "小红书号") {
        return "点赞/收藏";
      } else if (this.result3[index].type == "网易考拉海购号") {
        return "粉丝数";
      } else if (this.result3[index].type == "微信公众号") {
        return "平均阅读量";
      } else if (this.result3[index].type == "微博大V号") {
        return "平均转发量";
      }else if(this.result3[index].type == "app"){
        return "媒体领域"
      }
    },
    title4(index) {
      if (this.result3[index].type == "短视频") {
        return "粉丝数";
      } else if (this.result3[index].type == "小红书号") {
        return "笔记数量";
      } else if (this.result3[index].type == "网易考拉海购号") {
        return "文章数";
      } else if (this.result3[index].type == "微信公众号") {
        return "粉丝数";
      } else if (this.result3[index].type == "微博大V号") {
        return "平均点赞量";
      }else if(this.result3[index].type == "app"){
        return "售卖方式"
      }
    },
    content1(index) {
      return this.result3[index].about;
    },
    content2(index) {
      if (this.result3[index].type == "短视频") {
        return this.result3[index].platformName;
      } else if (this.result3[index].type == "小红书号") {
        return this.numLen(this.result3[index].fansTotal + "");
      } else if (this.result3[index].type == "网易考拉海购号") {
        return this.numLen(this.result3[index].likenumInt + "");
      } else if (this.result3[index].type == "微信公众号") {
        return this.result3[index].userId;
      } else if (this.result3[index].type == "微博大V号") {
        return this.numLen(this.result3[index].fansTotal + "");
      }else if (this.result3[index].type == "app") {
        return this.numLen(this.result3[index].monthToLive + "");
      }
    },
    content3(index) {
      if (this.result3[index].type == "短视频") {
        return this.result3[index].userId;
      } else if (this.result3[index].type == "小红书号") {
        return this.numLen(this.result3[index].likenumInt + "");
      } else if (this.result3[index].type == "网易考拉海购号") {
        return this.numLen(this.result3[index].fansTotal + "");
      } else if (this.result3[index].type == "微信公众号") {
        return this.numLen(this.result3[index].readingQuantity + "");
      } else if (this.result3[index].type == "微博大V号") {
        return this.numLen(this.result3[index].amountOfForwarding + "");
      }else if (this.result3[index].type == "app") {
        return this.result3[index].mediaSectorStr;
      }
    },
    content4(index) {
      if (this.result3[index].type == "短视频") {
        return this.numLen(this.result3[index].fansTotal + "");
      } else if (this.result3[index].type == "小红书号") {
        return this.numLen(this.result3[index].noteTheNumber + "");
      } else if (this.result3[index].type == "网易考拉海购号") {
        return this.numLen(this.result3[index].articleNum + "");
      } else if (this.result3[index].type == "微信公众号") {
        return this.numLen(this.result3[index].fansTotal + "");
      } else if (this.result3[index].type == "微博大V号") {
        return this.numLen(this.result3[index].likenumInt + "");
      }else if (this.result3[index].type == "app") {
        return this.result3[index].sellingWay;
      }
    },
    content5(index) {
      if(this.result3[index].type=="app"){
        return this.result3[index].appPrice
      }
      return this.result3[index].referencePrice;
    }
  },
  computed: {
    args() {
      return {
        page: this.page,
        limit: this.limit,
        order: this.order,
        sort: this.sort,
        id: this.userinfoid
      };
    }
  },
  mounted() {
    if (window.sessionStorage.getItem("userInfo")) {
      this.userinfoid = JSON.parse(
        window.sessionStorage.getItem("userInfo")
      ).userId;
      this.$ajax
        .post(this.Ipurl + "favoriteInfo/getListById", this.args)
        .then(res => {
          this.total = res.data.dataInfo.total;
          this.result3 = res.data.dataInfo.records;
          console.log(this.result3);
        });
    } else {
      this.$confirm("检测到您并没有登录", "warning", {
        confirmButtonText: "立即登录",
        cancelButtonText: "不了，谢谢",
        type: "warning"
      }).then(() => {
        this.$router.push("/login");
      });
    }
  }
};
</script>

<style scoped>
.container {
  width: 1200px;
  margin: 0 auto;
  margin-top: 50px;
  overflow: hidden;
  background: #fff;
}
.nav3 {
  width: 1200px;
  margin: 0 auto;
  margin-top: 20px;
  overflow: hidden;
  background: #fff;
}
.nav3 > div:nth-child(1) {
  float: left;
  width: 150px;
  height: 60px;
  line-height: 60px;
  text-align: center;
}
.nav3 > div:nth-child(1) > span {
  margin-left: 20px;
  font-size: 16px;
  font-weight: bold;
}
.nav3 > ul {
  float: left;
  overflow: hidden;
}
.nav3 > ul > li {
  float: left;
  width: 170px;
  height: 60px;
  line-height: 60px;
  font-size: 16px;
  cursor: pointer;
}
.nav3 > ul > li > span {
  margin-left: 10px;
}
.nav3 > ul > li > span.red {
  color: rgb(237, 64, 64);
}
.nav3 > ul > li > span.black {
  color: rgb(34, 34, 34);
}
.content {
  width: 1200px;
  margin: 0 auto;
  margin-top: 20px;
  overflow: hidden;
}
.list {
  overflow: hidden;
}
.list > li > ul > li {
  float: left;
  height: 200px;
  margin-top: 20px;
  background: #fff;
}
.list > li > ul > li:nth-child(1) {
  width: 190px;
  text-align: center;
  line-height: 200px;
  position: relative;
}
.list > li > ul > li:nth-child(1) > img:nth-child(2) {
  /* 下侧小图 */
  position: absolute;
  top: 115px;
  right: 50px;
}
.list > li > ul > li:nth-child(2) {
  width: 285px;
}
.list > li > ul > li:nth-child(2) > p:nth-child(1) {
  font-size: 18px;
  font-weight: bold;
  margin-top: 76px;
}
.list > li > ul > li:nth-child(2) > p:nth-child(2) {
  font-size: 14px;
  font-weight: bold;
  margin-top: 20px;
  color: rgb(34, 34, 34);
}
.list > li > ul > li:nth-child(3),
.list > li > ul > li:nth-child(4),
.list > li > ul > li:nth-child(5),
.list > li > ul > li:nth-child(6),
.list > li > ul > li:nth-child(7) {
  width: 100px;
  height: 200px;
  text-align: center;
}
.list > li > ul > li > p:nth-child(1) {
  font-size: 14px;
  font-weight: bold;
  margin-top: 76px;
}
.list > li > ul > li > p:nth-child(2) {
  font-size: 16px;
  font-weight: bold;
  margin-top: 20px;
  color: rgb(237, 64, 64);
}
.list > li > ul > li:last-child {
  width: 200px;
}
.list > li > ul > li:last-child > div {
  text-align: center;
}
.list > li > ul > li:last-child > div:nth-child(2) > button {
  width: 100px;
  height: 30px;
  border: 1px solid rgb(34, 34, 34);
  border-radius: 15px;
  margin-top: 16px;
  font-size: 14px;
  font-weight: bold;
  background: #fff;
}
.list > li > ul > li:last-child > div:nth-child(3) > button {
  width: 100px;
  height: 30px;
  border-radius: 15px;
  margin-top: 20px;
  color: #fff;
  background: rgb(237, 64, 64);
  font-size: 14px;
  font-weight: bold;
}
.page {
  margin-left: 250px;
}
</style>

